|
|
|
|
|
|
|
Listing 10.12. Coding the RSRead function. |
|
|
|
|
|
|
|
|
Private Function RSRead(frmTemp As Object)
'
' move data from recordset to form
'
On Error GoTo LocalErr
'
Dim ctlTemp As Control
Dim strTag As String
Dim strFldName As String
'
For Each ctlTemp In frmTemp.Controls
strTag = UCase(Trim(ctlTemp.Tag))
If strTag <> "" Then
If IsNull(rs.Fields(strTag)) = False Then
ctlTemp = rs.Fields(strTag)
End If
End If
Next
'
RSRead = 0
Exit Function
'
LocalErr:
RSRead = Err.Number
'
End Function |
|
|
|
|
|
|
|
|
This routine and the next routine (RSWrite) are the heart of the record-handling functions. When you understand how these routines work, you can build your own customized routines for handling dataset read and write operations. |
|
|
|
|
|
|
|
|
The routine in Listing 10.13 performs the opposite function of RSRead (see Listing 10.12). Again, it's a simple loop through all the controls on the form. If a control is bound to a data column, the value in the control is copied to the dataset column for storage. |
|
|
|
|
| |
|
|
|
|
Before you can write to a dataset, you need to invoke the Edit or AddNew methods. After the write operation, you must invoke the Update method to save the changes. You handle these operations in the button set routines later in today's lesson. |
|
|
|
|
|
|
|